<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>        
        <title>Facelet Title</title>
    </h:head>


    <h:body>       
        <div>
        <h:form prependId="false">
            <p:dialog header="Cadastro"
                      modal="true"
                      closable="false"
                      position="center"
                      widgetVar="dlg"
                      draggable="false"
                      width="1000"
                      height="600"
                      resizable="false"
                      visible="true"
                      id="dialog">

                <br/><br/><br/>

                <center>
                    <div>
                    <p:panel>
                        <p:panelGrid id="pgrid" columns="4" style="width:850px;">

                            <f:facet name="header">
                                Salvar
                            </f:facet>

                            <h:outputLabel for="nome" value="Nome:" />
                            <p:inputText value="#{pessoaMB.pessoa.nome}" id="nome"  style="width:300px;"/>  

                            <h:outputLabel for="mskcpf" value="CPF:" />
                            <p:inputMask mask="999.999.999-99"  value="#{pessoaMB.doc.cpf}" id="mskcpf"/>

                            <h:outputLabel for="mskcpf" value="RG:" />
                            <p:inputMask mask="99.99-999"  value="#{pessoaMB.doc.rg}" id="mskrg"/>

                            <h:outputLabel for="msknasc" value="Nasc:" />
                            <p:inputMask mask="99/99/9999"  value="#{pessoaMB.pessoa.dtNasc}" id="msknasc">
                                <f:convertDateTime pattern="dd/MM/yyyy" locale="pt,BR" type="date"/>
                            </p:inputMask>

                            <f:facet name="footer">
                                .
                            </f:facet>
                                
                        </p:panelGrid>
                    </p:panel>
                    </div>
                    <br/><br/><br/>
                    <div>
                    <p:panel>
                        <p:panelGrid id="pgrid2" columns="4" style="width: 800px;">

                            <f:facet name="header">
                                Endereco
                            </f:facet>

                            <h:outputLabel for="cep" value="CEP:" />
                            <p:inputMask mask="99.999-999"  value="#{pessoaMB.endereco.cep}" id="cep" >
                                <f:ajax event="blur"  render="cidade bairro logradouro"  execute="cep"
                                        listener="${pessoaMB.consultarEndereco()}"/>
                            </p:inputMask>
                             
                            <h:outputLabel for="cidade" value="Cidade:" /> 
                            <p:inputText value="${pessoaMB.endereco.cidade}" id="cidade"/>

                            <h:outputLabel for="bairro" value="Bairro:" /> 
                            <p:inputText value="${pessoaMB.endereco.bairro}" id="bairro"/>

                            <h:outputLabel for="logradouro" value="Logradouro:" />
                            <p:inputText value="#{pessoaMB.endereco.rua}" id="logradouro" style="width:400px;"/>

                            <f:facet name="footer">
                                <p:commandButton action="${pessoaMB.testeSalvar()}" id="salvar" value="Salvar" style="height:35px;"/> 
                            </f:facet>

                        </p:panelGrid>

                    </p:panel>
                    </div>
                    <div>
                    <f:facet name="footer" id="foot">                    
                        <center>Sistema Web de Cadastro<br/></center>
                    </f:facet> 
                    </div>
                </center>   
            </p:dialog>
        </h:form>
        </div>
    </h:body>    
</html>

